<?php

/**
 * Base request class for framework
 * 
 * PHP version 5
 * 
 * @category  Framework
 * @package   Abacus11_Framework
 * @author    Philippe Jausions <jausions@php.net>
 * @copyright 2008 11abacus / Philippe Jausions
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD
 * @link      http://pear.11abacus.com/package/Abacus11_Framework
 */

/**
 * Required ependencies
 */
require_once 'Abacus11/Framework/DataHolder.php';
require_once 'Abacus11/Framework/Request/Attachments.php';

/**
 * Base request class for framework
 * 
 * @category  Framework
 * @package   Abacus11_Framework
 * @author    Philippe Jausions <jausions@php.net>
 * @copyright 2008 11abacus / Philippe Jausions
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD
 * @link      http://pear.11abacus.com/package/Abacus11_Framework
 * 
 * @property-read Abacus11_Framework_Request::TYPE_*     $type        Request type
 * @property      Abacus11_Framework_Request_Attachments $attachments Attachments list
 */
class Abacus11_Framework_Request extends Abacus11_Framework_DataHolder  
{
    /**
     * The request is mostly to retrieve information and should have
     * minimum effect
     */
    const TYPE_RETRIEVE = 'get';

    /**
     * The request is went to submit information which most likely will
     * have a long term effect
     */
    const TYPE_SUBMIT = 'post';

    /**
     * The request is simply a request for meta-information
     */
    const TYPE_INFO = 'head';

    /**
     * Request type
     *
     * @var Abacus11_Framework_Request::TYPE_* constant
     */
    protected $type;

    /**
     * Attachments list
     *
     * @var Abacus11_Framework_Request_Attachements
     */
    protected $attachments;
    
    /**
     * Class constructor
     *
     * @param Abacus11_Framework_Request::TYPE_* $type Type constant
     * @param array                              $data Array-like data
     */
    public function __construct($type, $data)
    {
        parent::__construct($data);
        $this->type        = $type;
        $this->attachments = new Abacus11_Framework_Request_Attachments();
    }

    /**
     * Property setter
     *
     * @param string $name  Property name
     * @param mixed  $value New property value
     * 
     * @return void
     */
    public function __set($name, $value)
    {
        throw new Abacus11_Framework_Exception_NotFound('No such writable property "'
                .$name.'"', Abacus11_Framework::SCOPE_REQUEST);
    }
    
    /**
     * Property getter
     *
     * @param string $name Property name
     * 
     * @return mixed
     */
    public function __get($name)
    {
        switch ($name) {
        case 'type':
        case 'attachments':
            return $this->$name;
        }
        throw new Abacus11_Framework_Exception_NotFound('No such property "'
                .$name.'"', Abacus11_Framework::SCOPE_REQUEST);
    }
    
    /**
     * Returns the URL that matches the request
     *
     */
    public function getURL()
    {
        
    }
}

?>